<?php
class editAction extends rareAction{
    public function execute(){
		$id = $this->getGetParam('id',0);
		if($id!=0){
			$menuDao = new DaoMenu();
			$menu = $menuDao->getOne("id='$id'");
			$this->assign('menu',$menu);
		}
	}
	public function executePost(){
		$id = $this->getPostParam('id',0);
		if($id==0) jsonReturn(0,'错误的参数');
		$menu = $this->getPostParam('menu',array());
		if(!empty($menu)){
			$menuDao = new DaoMenu();
			$menu['title'] = trim($menu['title']);
			//$re = $menuDao->insert($menu);
			$parent = $menuDao->getOne('id='.$menu['parentID']);
			$menu['path'] = empty($parent)?"0,$id":$parent['path'].",$id";
			$menuDao->update("id='$id'",$menu);
			jsonReturn(1,'ok');
		}
		jsonReturn(0,'错误的参数');
	}
}
?>
